package com.ls.datalog.domain;

public enum ActionType {
	
	INSERT("insert",1),//先定义实例
	UPDATE("update",2),//在写构造方法
	DELETE("delete",3);//最后写成员及其他方法
	
	ActionType(String name,int index) {
		this.name=name;
		this.index=index;
	}
	
	 String name;
	 int index;
	 
	 public static String getName(int index) {
		 for(ActionType t : values()) {
			 if(t.getIndex()==index)
				 return t.getName();
		 }
		 return null;
	 }
	 
	 public static int getIndex(String name) {
		 for(ActionType t : values()) {
			 if(t.getName().equalsIgnoreCase(name))
				 return t.getIndex();
		 }
		 return 0;
	 }
	 
	 public static ActionType getType(String name) {
		 for(ActionType t : values()) {
			 if(t.getName().equalsIgnoreCase(name))
				 return t;
		 }
		 return null;
	 }
	 
	public String getName() {
		return name;
	}
	public int getIndex() {
		return index;
	}
	
	
	 
}
